home *** CD-ROM | disk | FTP | other *** search
/ Freaks Macintosh Archive / Freaks Macintosh Archive.bin / Freaks Macintosh Archives / Hacking & Misc / bundle of exploits.sit / bundle of exploits / lookup.c < prev    next >
C/C++ Source or Header  |  1995-10-14  |  740b  |  31 lines

  1. /*translate ip to alpha, faster than nslookup*/
  2. /*thc*/
  3. #include <sys/types.h>
  4. #include <sys/socket.h>
  5. #include <netinet/in.h>
  6. #include <arpa/inet.h>
  7. #include <netdb.h>
  8. #include <stdio.h>
  9.  
  10. main(argc, argv)
  11. int argc;
  12. char *argv[];
  13.  
  14. {  
  15.   struct hostent *lookup;
  16.   char           name[255];
  17.   unsigned long  addr;
  18.  
  19.   if (argc != 2) {
  20.       printf("Usage:  %s {ipnumber}\n", argv[0]);
  21.       exit(1); } 
  22.  if ((addr = inet_addr(argv[1])) == -1) {
  23.       printf("Couldn't find %s\n", argv[1]);
  24.       exit(1); }
  25.   if ((lookup = gethostbyaddr((char *) &addr,sizeof(long),AF_INET)) != NULL) {
  26.       printf("%s \t %s\n",argv[1], lookup->h_name);
  27.       *lookup->h_addr_list++; }  
  28.   else
  29.     printf("Error: couldn't find hostname for %s\n", argv[1]);
  30.   }
  31.